﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;

namespace XMM.Dialoges
{
    /// <summary>
    /// Interaktionslogik für MobileDeviceFeeder.xaml
    /// </summary>
    public partial class MobileDeviceFeeder : Window
    {
        private XMM.Library ParentLibrary { get; set; }
        private int SelectedAudience { get; set; }

        /// <summary>
        /// Initialize a new Mobile Device Feeder Dialog.
        /// </summary>
        /// <param name="dlgParentLibrary"></param>
        public MobileDeviceFeeder(XMM.Library dlgParentLibrary)
        {
            InitializeComponent();

            ParentLibrary = dlgParentLibrary;
            SelectedAudience = ParentLibrary.SelectedAudition.AuditionID;
        }

        /// <summary>
        /// Load selected objects.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Load selected Movies.
            startMovieProcessing();

            // Load selected Shows.
            startShowProcessing();
        }

        /// <summary>
        /// Start Movie-Processing-Thread.
        /// </summary>
        private void startMovieProcessing()
        {
            Thread thProcessMovies = new Thread(new ThreadStart(processMovies));
            thProcessMovies.Start();
        }

        /// <summary>
        /// Process selected Movies.
        /// </summary>
        private void processMovies()
        {

        }

        /// <summary>
        /// Start Show-Processing-Thread.
        /// </summary>
        private void startShowProcessing()
        {
            Thread thProcessShows = new Thread(new ThreadStart(processShows));
            thProcessShows.Start();
        }

        /// <summary>
        /// Process selected Shows.
        /// </summary>
        private void processShows()
        {

        }

        /// <summary>
        /// Set Status with undefined progress (marquee).
        /// </summary>
        /// <param name="sNewMessage">(string) New Status Message.</param>
        /// <param name="bMarqueeEnabled">(bool) [true] to enable progressbar-marquee.
        /// [false] to disable.</param>
        private void setStatus(string sNewMessage, bool bMarqueeEnabled)
        {
            lblStatus.Content = sNewMessage;
            pbStatus.IsIndeterminate = bMarqueeEnabled;
        }

        /// <summary>
        /// Set Status with undefined progress (marquee). CALLBACK
        /// </summary>
        /// <param name="sNewMessage">(string) New Status Message.</param>
        /// <param name="bMarqueeEnabled">(bool) [true] to enable progressbar-marquee.
        /// [false] to disable.</param>
        private delegate void setStatusCallback(string sNewMessage, bool bMarqueeEnabled);

        /// <summary>
        /// Set Status with definded progress (percentage).
        /// </summary>
        /// <param name="sNewMessage">(string) New Status Message.</param>
        /// <param name="iProgress">(int) current Progress in percent.</param>
        private void setStatus(string sNewMessage, int iProgress)
        {
            if (iProgress < 0)
                iProgress = 0;
            else if (iProgress > 100)
                iProgress = 100;

            lblStatus.Content = sNewMessage;
            pbStatus.IsIndeterminate = false;
            pbStatus.Value = iProgress;
        }

        private delegate void setStatusCallback(string sNewMessage, int iProgress);
    }
}
